<%@ page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.HashMap"%>
<html>
<head>
<title>主页面</title>
<!-- ExtJS -->
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/public/extjs/resources/css/ext-all.css" />
<script type="text/javascript"
	src="<%=request.getContextPath()%>/public/extjs/ext-all.js"></script><script type="text/javascript"	src="<%=request.getContextPath()%>/public/include/js/component.js"></script><script type="text/javascript" src="<%=request.getContextPath()%>/public/include/js/api/appdeal.js"></script>

<!-- GC -->

</head>
<body>

</body>
<script language="javascript">
	Ext.require( [ '*' ]);
	Ext.onReady( function() {
		var cw;

		function closeRegion(e, target, header, tool) {
			var region = header.ownerCt;
			newRegions.unshift(region.initialConfig);
			viewport.remove(region);
		}

		var newRegions = [ {
			region :'north',
			title :'North 2',
			height :100,
			collapsible :true,
			collapsed: true, //默认缩里面
			weight :-120
		}, {
			region :'east',
			title :'East 2',
			width :100,
			collapsible :true,
			collapsed: true, //默认缩里面
			weight :-110
		}, {
			region :'west',
			title :'West 2',
			width :100,
			collapsible :true,
			collapsed: true, //默认缩里面
			weight :-110
		} ];
		//------------------系统模块-----------------------------------------
		<%List<Map<String, String>> list = new ArrayList<Map<String, String>>();
		Map<String, String> ms = new HashMap<String, String>();
		ms.put("id", "11");
		ms.put("text", "业务菜单");
		list.add(ms);
		//(List<Map<String, String>>)request.getAttribute("modules");
		for(int i = 0; i < list.size(); i++){
		//for(int i = 0; i < 1; i++){%>

			var store<%=i%> = Ext.create('Ext.data.TreeStore', {
				proxy : {
					type :'ajax',
					url :'sysright_getChildMenus.do'
				},
				root : {
					text :'<%=list.get(i).get("text")%>',
					id :'<%=list.get(i).get("id")%>',
					expanded :true
				},

				nodeParam : 'id'
				
			});


			var item<%=i%> = Ext.create('Ext.tree.Panel', {
				store :store<%=i%>,
				rootVisible : false,
				minheight :20,
				height :300,
				width :250,
				collapsible : true,
				collapsed: true, //默认缩里面
				split : true,
				title :'<%=list.get(i).get("text")%>',
				listeners:{'itemclick':tree_event},
				useArrows :true

				
			});
			

		<%}//for%>
			
			function tree_event(treeview, record, item, index, e, opts){  
	            addTab(record.data.qtitle,record.data.text,record.data.id,record.data.text,'tab-bar-default-top-bg.gif');
	        };  
			
			//--------------------------------------------------------------------------
			var mainTabs = Ext
					.create(
							'Ext.TabPanel',
							{
								region :'center',
								activeTab :0,
								id :'mainTabs',
								enableTabScroll :true,
								height :550,
								border :false,
								frame :true,
								items : [ {
									title :"我的任务",
									listeners : {
										activate : function() {
											//Ext.getCmp('centerPanel').setTitle('我的工作台');
										}
									},
									html :"<iframe name='mainFrame'  src='workflow_myWorkFrame.do' scrolling='auto' frameborder='0' width='100%' height='100%' ></iframe>"
								} ]
							});

			var menus = Ext.create('Ext.Panel', {
				title :'主菜单',
				collapsible :true,
				collapsed: true, //默认缩里面
				region :'west',
				margins :'0 0 0 0',
				split :true,
				width :260,
				maxWidth :800,
				layout :'accordion',
				items : [ <%for(int i = 0; i < list.size(); i++){
					out.print("item" + i);
					if(i < list.size() - 1){
						out.print(",");
					}
				}%> ]
			});
			/**
			 * 响应树节点单击事件
			 */
			function addTab(url, name, menuid, pathCh, icon) {
				var id = "tab_id_" + menuid;
				if (url == '#' || url == '') {
					//Ext.Msg.alert("提示信息", '此菜单还没有指定请求地址,无法为您打开页面.');
					setStatus('此菜单还没有指定请求地址,无法为您打开页面.');
				} else {
					var index = url.indexOf('?');
					if (index != -1){
						url = '<%=request.getContextPath()%>' + url + '&menuid=' + menuid + '&menuname=' + name;
					}else{
						url = '<%=request.getContextPath()%>' + url + '?menuid=' + menuid + '&menuname=' + name;
					}
					var n = mainTabs.getComponent(id);
					if (!n) {
						// 如果对centerPanel进行遮罩,则可以出现阴影mainTabs
						//Ext.getCmp('centerPanel').getEl().mask('<span style=font-size:12>正在加载页面,请稍等...</span>', 'x-mask-loading');
						// document.getElementById('endIeStatus').click();//解决Iframe IE加载不完全的问题
						// 兼容IE和FF触发.click()函数
						var endIeStatus = document.getElementById("endIeStatus");
						if (document.createEvent) {
							//var ev = document.createEvent('HTMLEvents');
							//ev.initEvent('click', false, true);
							//endIeStatus.dispatchEvent(ev);
						} else{
							//endIeStatus.click();
						
						}
						n = mainTabs
								.add( {
									id :id,
									//title :"<img align='top' class='IEPNG' src='./resource/ext-theme-acctss/images/tab-bar/"
									//		+ icon + "'/>" + name,
									title : name,
									closable :true,
									layout :'fit',
									listeners : {
										activate : function() {
											//Ext.getCmp('centerPanel').setTitle(pathCh)
										}
									},
									html :'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src=' + url + '></iframe>'
								//如果功能页面使用中心区域阴影加载模式则使用下面的代码unmaskCenterPanel();页面加载完毕后取消阴影
								//html:'<iframe scrolling="auto" frameborder="0" onload="unmaskCenterPanel()" width="100%" height="100%" src='+url+'></iframe>'
								});
					}else{
			            var updateHtml = '<iframe  scrolling="auto" frameborder="0" width="100%" height="100%" src=' + url + '></iframe>';
						Ext.getCmp(id).update(updateHtml);
					}
					mainTabs.setActiveTab(n);
					setStatus('就绪');
				}
			}
			
			var statusBar = new Ext.Panel({ 
				region :'south',
				id : 'statusBar',
				collapsible :false,
				collapsed: true, //默认缩里面
				split :false,
				height :25,
				minHeight :25,
			    title: '就绪'
			    // etc.
			    /**
			    bbar: Ext.create('Ext.ux.StatusBar', {
            		defaultText: 'Default status',
            		id: 'right-statusbar',
            		statusAlign: 'right', // the magic config
            		items: [{
                		text: 'A Button'
            			}, '-', 'Plain Text', ' ', ' ']
        		})
        		*/
			    
			});

			window.setStatus = function setStatus(title){
				Ext.getCmp('statusBar').setTitle(title);
			}


			//--------------------------------------------------------------------------
			var viewport = Ext.create('Ext.Viewport', {
				layout : {
					type :'border',
					padding :5
				},
				defaults : {
					split :true
				},
				items : [ {
					region :'north',
					collapsible :true,
					collapsed: true, //默认缩里面
					title :'一体化系统',
					split :true,
					height :60,
					minHeight :30,
					html :'north'
				}, menus, {
					region :'center',
					id :'centerPanel',
					iconCls :'',
					//title :'XLINK',
					autoScroll :false,
					layout :'fit',
					items : [ mainTabs ]
				},statusBar
				]
			});
		});
	
	//创建全屏窗口，比如我的任务中的业务处理
	function createExtWindow(windowConfig){
		var extWindow = Ext.create('Ext.window.Window', windowConfig);
		return extWindow;
	}
</script>
</html>